package com.kws.merchant.mapper;

import com.kws.merchant.domain.OrderPayLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;


/**
 * 订单支付记录(OrderPayLog)表数据库访问层
 *
 * @author yxy
 * @since 2024-11-20 14:32:16
 */

public interface OrderPayLogMapper extends BaseMapper<OrderPayLog> {

    /**
     * 商家统计支付-退款金额
     * @param userId
     * @param payType
     * @param time
     * @return
     */
    @Select("select  count(price) from tb_order_pay_log where merchant_id='${userId}' and pay_type=${payType} and DATE(create_time) like '${time}'")
    Double payCountByTime(@Param("userId") Long userId,@Param("payType") int payType,@Param("time") String time);

    /**
     * 昨日订单数量统计
     * @param userId
     * @param payType
     * @param time
     * @return
     */
    @Select("select  count(DISTINCT order_no) from tb_order_pay_log where merchant_id='${userId}' and pay_type=${payType} and DATE(create_time) like '${time}'")
    Double yesterdayOrderCount(@Param("userId") Long userId,@Param("payType") int payType,@Param("time") String time);

    /**
     * 总在途订单金额
     * @param userId
     * @param payType
     * @return
     */
    @Select("select  count(price) from tb_order_pay_log where merchant_id='${userId}' and pay_type=${payType}")
    Double payCount(@Param("userId") Long userId,@Param("payType") int payType);

    /**
     * 总用户退款金额
     * @param userId
     * @param payType
     * @return
     */
    @Select("select  count(price) from tb_order_pay_log where merchant_id='${userId}' and pay_type=${payType}")
    Double countPayCount(@Param("userId") Long userId,@Param("payType") int payType);

    /**
     * 总在途订单数
     * @param userId
     * @param payType
     * @return
     */
    @Select("select  count(DISTINCT order_no) from tb_order_pay_log where merchant_id='${userId}'")
    Double countOrderCount(@Param("userId") Long userId,@Param("payType") int payType);
}
